﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ConnectionControl;

namespace pokerServer.ProtHandlers
{
	class seatProtHandle :absTableSeatHandler
	{

		public seatProtHandle(ConnectionManag cm, String[] synt)
		{
			this.cm = cm;
			this.synt = synt;
		}

		public override String work()
		{
			try
			{
				int tableId = Int32.Parse(synt[1]);
				int seatId = Int32.Parse(synt[2]);
				TableErrors t = 0;
				//this.cm.joinSeat(tableId, seatId, synt[3], out t);
				return analyze(t);
			}
			catch (Exception e)
			{
				return e.Message;
			}
		}

		public override String analyze(TableErrors t)
		{
			String ans = "";
			switch (t)
			{
				case TableErrors.ERR_TableSeatNotExist:
					ans = "SEAT-FAIL SeatOrTableNotExist";
					break;
				case TableErrors.ERR_TableSeatJoined:
					ans = "SEAT-ACK";
					break;
				case TableErrors.ERR_SeatTaken:
					ans = "SEAT-FAIL SeatTaken";
					break;
				default:
					ans = "SEATUNKNOWN ERROR DEBUG LAST COMMAND!";
					break;
			}
			return ans;
		}
	}
}
